
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>修改登录密码</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@1.6/lib/index.css">
		<script src="../../js/vue.min.js"></script>
		<script src="../../js/vue-toasted.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/vant.min.js"></script>
		<script src="html5plus://ready"></script>
		<script src="../../js/listener_other.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/ajax.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			<head>
				<van-nav-bar title="修改登录密码" left-text="" right-text="确认修改" left-arrow @click-left="onClickLeft" @click-right="onClickRight" ></van-nav-bar>
			</head>
			<section>
				<van-cell-group>
					<van-field v-model="phone" center clearable label="手机号">
						
					</van-field>
					<van-field v-model="phonecode" center clearable label="短信验证码">
						<van-button slot="button" size="small" type="danger" @click="getcode">发送验证码</van-button>
					</van-field>
					<van-field  type="password" v-model="password" label="登录密码" placeholder="最少6位" required>
						
					</van-field>
					<van-field  type="password" label="确认密码" placeholder="再次输入登录密码" required></van-field>
					<van-button type="warning" size="large" center @click="ljxg">修改密码</van-button>
				</van-cell-group>
				
			</section>
			<footer>
				<van-icon name="info-o" />系统将会向您绑定的手机号码发送一条短信
			</footer>
		</div>
		<script>
			var newUser = localStorage.getItem("user");
			newUser = JSON.parse(newUser);
			key=newUser.Key;
			Vue.use(Toasted);
			var vm = new Vue({
				el: "#app",
				data: {
					sms:"",
					phone:"",
					password:"",
					phonecode:"",
					key:newUser.Key
				},
				 methods: {
					getcode:function(){
						console.log(this.key);
						console.log(vm.phonecode);
						ajax({
							url: "http://dsapi.ysd3g.com/API/SendChangePasswordCode",
							dataType: "jsonp",
							data: {
								key:key
							},
							success: function(result) {
								console.log(result);
								if (result.Error) {
									vm.$toasted.error("发送失败",{position:"bottom-center",duration:2000});
								}
								else{
									console.log(result);
									vm.phonecode=result.Code;
									vm.$toasted.success("您的验证码为"+result.Code,{position:"bottom-center",duration:5000});
// 									$.post('http://www.54cjk.cn/Gbook/getsend',{phone:vm.phone}, function (data) {
// 										vm.$toasted.success("您的验证码为"+data.Code,{position:"bottom-center",duration:5000});
// 										vm.code=data.Code;
// 										console.log(data);
// 									});
								}
							}
						})
					},
					ljxg:function(){
						ajax({
							url: "http://dsapi.ysd3g.com/API/ChangePassword",
							dataType: "jsonp",
							data: {
								key:key,password:vm.password,phoneCode:vm.phonecode
							},
							success: function(result) {
								if (result.Error) {
									vm.$toasted.error("您的手机号码不正确",{position:"bottom-center",duration:2000});
								}
								else{
									vm.$toasted.success("密码修改成功",{position:"bottom-center",duration:5000});
									vm.phonecode=result.Code;
									console.log(result);
									localStorage.clear();//清除用户信息 
									var personal=plus.webview.getWebviewById("PersonalCenter");
									personal.reload(true);
									//plus.webview.open("PersonalCenter.html", "PersonalCenter");
									plus.webview.close(plus.webview.currentWebview(),"slide-out-left");//关闭当前页面,返回个人中心
								}
							}
						})
					},
					onClickLeft() {
					  plus.webview.close(plus.webview.currentWebview(), "slide-out-left");
					},
					onClickRight() {
					  alert('已修改');
					}
				  }
			})
		</script>
	</body>
</html>
